package com.school.controller;

import java.time.LocalDateTime;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.PageInfo;
import com.school.pojo.Menu;
import com.school.service.MenuService;
import com.school.util.Result;
import com.school.util.Tool;

@RequestMapping("/menu")
@RestController
public class MenuController implements Tool<Menu>{

	@Autowired
	private MenuService menuService;
	
	
	@Override
	@RequestMapping("/findAll")
	public Result<Menu> findAll(@RequestParam(defaultValue = "1",name="page")int page,@RequestParam(defaultValue = "10",name="limit")int pageSize,Menu menu) {
		List<Menu> list= menuService.findAll(menu,page,pageSize);
		PageInfo<Menu> info=new PageInfo<>(list);
		Result<Menu> result=new Result<Menu>();
		result.setList(info.getList());
		result.setCount(info.getTotal());
		return result;
	}

	@Override
	public Result<Menu> findbyId(int id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	@RequestMapping("/add")
	public int add(Menu t) {
		return menuService.add(t);
	}

	@Override
	public int edit(Menu t) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int del(int id) {
		
		return 0;
	}

	@Override
	@RequestMapping("/delbatch")
	public int delbatch(@RequestParam(name = "ids[]")int[] ids) {
		return menuService.delbatch(ids);
	}



	
}
